package cn.globalph.housekeeper.ui.dialog

import android.os.Build
import android.util.TypedValue
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import cn.globalph.housekeeper.utils.SystemUtils

open class BaseDialogFragment :DialogFragment(){
    override fun show(manager: FragmentManager, tag: String?) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if (manager.isDestroyed) {
                return
            }
        }
        val ft = manager.beginTransaction()
        ft.add(this, tag)
        ft.commitAllowingStateLoss()
    }

    fun dp2px(dpVal: Float): Int {
        return TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,
            dpVal,
            resources.displayMetrics
        ).toInt()
    }

    fun TT(msg:String){
        SystemUtils.TT(context,msg)
    }
}